# -*- coding: utf-8 -*-
import os
from liberHook.BaseHook import BaseHook
from liberLibs.dccLibs import Nuke
import liberConfig


class Hook(BaseHook):
    def __init__(self, library, directory, ext, start, end):
        super(Hook, self).__init__(library, directory, ext, start, end)

    def execute(self):
        if not self.files:
            self.append_error("No nuke files found.")
            return
        for f in self.files:
            ext = os.path.splitext(f)[-1]
            if ext in liberConfig.NUKE_EXT:
                Nuke.open_file(f)
                return
